/*
	Name: 倒酒 
	Author: There,hello 
	Date: 14-10-19 13:22
	Description: Luogu P1292 
	Algorithm: 扩展gcd 
*/
#include<bits/stdc++.h>
using namespace std;
int x,y;
int gc;
void ex_gcd(int a,int b){
	if(b==0){
		x=1;
		y=0;
		gc=a;	
		return;
	}
	ex_gcd(b,a%b);
	int t=x;
	x=y; y=t-(a/b)*y;
}
int main(){
	int n,m;
	cin>>n>>m;
	ex_gcd(m,n);
	cout<<gc<<endl;
	y=-y;
	y=((y%(m/gc))+(m/gc))%(m/gc);
	cout<<y<<" "<<((long long)gc+(long long)n*(long long)y)/m;
}
